package felix.rule.data.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.JsonNode;
import felix.rule.data.msg.RuleNode;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

@EqualsAndHashCode(callSuper = true)
@TableName("rule_node")
@Data
@NoArgsConstructor
public class RuleNodeEntity extends BaseEntity<RuleNode> {

    private String ruleChainId;
    private String name;
    private String type;
    private boolean debugMode;
    private JsonNode additionalInfo;
    private JsonNode configuration;

    public RuleNodeEntity(RuleNode node) {
        BeanUtils.copyProperties(node, this);
    }

    @Override
    public RuleNode toData() {
        RuleNode ruleNode = new RuleNode();
        BeanUtils.copyProperties(this, ruleNode);
        return ruleNode;
    }
}
